package com.zdd.ehe.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zdd.ehe.entity.Environment;
import com.zdd.ehe.param.EnvironmentParam;
import com.zdd.ehe.param.TypeParam;
import com.zdd.ehe.result.Result;
import com.zdd.ehe.service.EnvironmentService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version 1.0.0
 * @title: HelpController
 * @author: HFLy
 * @description:
 * @date: 18/3/2023 下午8:56
 */
@Api(tags = "农业助手模块")
@RestController
@RequestMapping("/help")
public class HelpController  {
    @Autowired
    private EnvironmentService environmentService;

    @PostMapping("/getInfo")
    public Result getInfo(TypeParam typeParam){
        Environment one = environmentService.getOne(new QueryWrapper<Environment>()
                .eq("name", typeParam.getType())
        );
        return Result.success("查询成功", one);
    }
    @PostMapping("/search")
    public Result search(@RequestBody EnvironmentParam environmentParam){
        List<Environment> list = environmentService.search(environmentParam);
        return Result.success("查询成功",list);
    }
}
